<template>
  <div id="app">
    <!-- <nav>
        <router-link to="/">Home</router-link> |
        <router-link to="/about">About</router-link>
      </nav> -->
    <router-view />
  </div>
</template>

<script>
import { mapActions } from 'vuex';
export default {
  name: "RootView",
  methods: {
    ...mapActions("authority", ["getAuthorityInfo"])
  },

  // 组件初始化时执行 
  async created() {
    if (this.$route.path != "/login" && this.$route.name != "notFound") { //非登录页面
      var info = await this.getAuthorityInfo(); //action方法默认返回Promise实例 (成功=>对象数据  失败 => "")
      // console.log(11111,info);
      if (!info) {//用户没有登录
        this.$message.error("请先登录账号");
        this.$router.replace({ path: "/login", query: { ReturnURL: this.$route.fullPath } })
      }
    }
  }
}

</script>


<style>
html,
body,
#app {
  width: 100%;
  height: 100%;
}
</style>
